package com.elio.seatademostorage.impl;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elio.seatademostorage.StorageTblService;
import com.elio.seatademostorage.mybatis.entity.StorageTbl;
import com.elio.seatademostorage.mybatis.mapper.StorageTblMapper;
import lombok.var;
import org.springframework.stereotype.Service;

/**
* 库存
*/
@Service
public class StorageTblServiceImpl extends ServiceImpl<StorageTblMapper, StorageTbl>
implements StorageTblService {

    @Override
    public void deduct(String commodityCode, int count) {
        var wrapper = new LambdaUpdateWrapper<StorageTbl>();
        wrapper.setSql("count = count - " + count)
                .eq(StorageTbl::getCommodityCode, commodityCode);
        this.update(wrapper);
    }
}
